using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;


namespace BUS
{
    public class NHANVIENBUS
    {
        public static void Insert(NHANVIEN nv)
        {
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            nvDAL.Insert(nv);
        }
        public static void Update(NHANVIEN nv)
        {
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            nvDAL.Update(nv);
        }
        public static void Delete(int iD)
        {
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            nvDAL.Delete(iD);
        }
        public static Nhan_vienCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            return nvDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Nhan_vienCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            return nvDAL.Get(cri.Criter, 0, 0, Nhan_vienColumns.Manv.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static NHANVIEN GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Nhan_vienColumns.Manv.ToString(), Condition.EQUAL, iD);
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            Nhan_vienCollection nhanvienCollection = nvDAL.Get(cri.Criter, 0, 0, Nhan_vienColumns.Manv.ToString(), OrderDirection.ASC.ToString(), out total);
            if (nhanvienCollection.Count > 0)
                return nhanvienCollection[0];
            return null;
        }
        public static Nhan_vienCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            return nvDAL.Get(cri.Criter, 1, number,
             Nhan_vienColumns.Manv.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static Nhan_vienCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            NHANVIENDAL nvDAL = new NHANVIENDAL();
            return nvDAL.Get(cri.Criter, 1, number,
               Nhan_vienColumns.Manv.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
